﻿-- Ajouter ModifiedOn sur la table Localizations
IF NOT EXISTS ( 
Select * FROM Information_Schema.COLUMNS
where TABLE_SCHEMA = 'dbo'
AND TABLE_NAME = 'Localizations'
AND Column_Name = 'ModifiedOn'
)
BEGIN
ALTER TABLE dbo.Localizations
ADD ModifiedOn datetime
CONSTRAINT DF_Localizations_ModifiedOn DEFAULT GETUTCDATE() NOT NULL
END


-- Ajouter la table de configurations Medianamik
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[medianamik_Configuration]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[medianamik_Configuration](
	[Key] [nvarchar](50) COLLATE SQL_Latin1_General_CP1_CI_AI NOT NULL,
	[Value] [nvarchar](max) COLLATE SQL_Latin1_General_CP1_CI_AI NULL,
 CONSTRAINT [PK_medianamik_Configuration] PRIMARY KEY CLUSTERED 
(
	[Key] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END

IF (NOT EXISTS(SELECT 1 FROM Localizations WHERE ResourceId = 'LockInfoTooltipMessage_UnknownLock' AND LocaleId = 'fr-ca' AND ResourceSet = 'Medianamik_LockManagement'))
	INSERT INTO Localizations(ResourceId, Value, LocaleId, ResourceSet) VALUES('LockInfoTooltipMessage_UnknownLock', 'L''information sur ce verrou n''est plus disponible.', 'fr-ca', 'Medianamik_LockManagement')
ELSE
	UPDATE Localizations SET Value = 'L''information sur ce verrou n''est plus disponible.' WHERE ResourceId = 'LockInfoTooltipMessage_UnknownLock' AND LocaleId = 'fr-ca' AND ResourceSet = 'Medianamik_LockManagement'	
IF (NOT EXISTS(SELECT 1 FROM Localizations WHERE ResourceId = 'LockInfoTooltipMessage_UnknownLock' AND LocaleId = 'en-ca' AND ResourceSet = 'Medianamik_LockManagement'))
	INSERT INTO Localizations(ResourceId, Value, LocaleId, ResourceSet) VALUES('LockInfoTooltipMessage_UnknownLock', 'No more information for this lock.', 'en-ca', 'Medianamik_LockManagement')	
ELSE
	UPDATE Localizations SET Value = 'No more information for this lock.' WHERE ResourceId = 'LockInfoTooltipMessage_UnknownLock' AND LocaleId = 'en-ca' AND ResourceSet = 'Medianamik_LockManagement'